<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>九九乘法表</title>
</head>
<body>
    <table border="1">
        <tbody id="tbody"></tbody>
    </table>
    <script>
        let tbody = document.getElementById("tbody");
        // for(let i = 1;i <= 9;i++){
        //     let tr = document.createElement("tr");
        //     for(let j = 1;j <= i;j++){
        //         let td = document.createElement("td");
        //         let txt = document.createTextNode(`${j} * ${i} = ${i * j}`);
        //         td.appendChild(txt);
        //         tr.appendChild(td);
        //     }
        //     tbody.appendChild(tr);
        // }
        let str = "";
        for(let i = 1;i <= 9;i++){
            let tdStr = "";
            for(let j = 1;j <= i;j++){
                tdStr += `<td>${j} * ${i} = ${i * j}</td>`;
            }
            str += "<tr>"+tdStr+"</tr>";
        }
        console.log(str);
        tbody.innerHTML = str;
    </script>
</body>
</html>